<?php
/**
 * ============================================================================
 * 版权所有 2008-2011 多多网络，并保留所有权利。
 * 网站地址: http://soft.duoduo123.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
*/
session_start();
error_reporting(0);
include_once 'comm/config.php';
include_once 'comm/Taoapi.php';
include_once 'comm/page.class.php';
include_once 'plugins/nokeywords.php';
include_once 'comm/checkpostandget.php';

$page=empty($_GET['page'])?'1':$_GET['page'];
$pagesize=PAGESIZE;
$q=empty($_GET['q']) ? '' : $_GET['q']; 
if($q=='请输入商品名称...'){$q='';}
$cid = empty($_GET['cid'])?'':intval($_GET['cid']);
if($q==''&&$cid==''){$q=HOTWORD;}
$sort=empty($_GET['sort']) ? MORESORT : $_GET['sort']; 
$start_price=empty($_GET['start_price'])?'0':intval($_GET['start_price']);
$area=empty($_GET['area'])?'':($_GET['area']);
$end_price= empty($_GET['end_price'])?'999999':($_GET['end_price']);
$start_credit=empty($_GET['start_credit'])?'':intval($_GET['start_credit']);
$end_credit=empty($_GET['end_credit'])?'':intval($_GET['end_credit']);
$list=$_GET['list'];
if($list!=''){$_SESSION['list']=$list;}
if($list==''){
	$list=$_SESSION['list'];
	if($list==''){$list=LIEBIAO;}
}
//获取该cid下商品列表
$Taoapi_Config = Taoapi_Config::Init();
$Taoapi_Config->setCharset('UTF-8');
$Taoapi = new Taoapi;

$Taoapi->method = 'taobao.taobaoke.items.get';
$Taoapi->fields = 'iid,num_iid,title,nick,pic_url,price,click_url,shop_click_url,commission,commission_rate,commission_num,commission_volume,volume';
$Taoapi->nick = MYUSERNICK;
$Taoapi->cid=$cid;
$Taoapi->keyword=$q;
$Taoapi->start_credit=$start_credit;
$Taoapi->end_credit=$end_credit;
$Taoapi->start_price=$start_price;
$Taoapi->end_price=$end_price;
$Taoapi->sort=$sort;
$Taoapi->area=$area;
$Taoapi->page_no=$page;
$Taoapi->page_size=$pagesize;
$Taoapi->outer_code = $_SESSION['dduserid'];
$TaobaokeData = $Taoapi->Send('get','xml')->getArrayData();
$TaobaokeItem1 = $TaobaokeData["taobaoke_items"]["taobaoke_item"]; 
$TotalResults = $TaobaokeData["total_results"]; 
if($TotalResults==1){
	$TaobaokeItem2[0]=$TaobaokeItem1;
}else{
	$TaobaokeItem2=$TaobaokeItem1;
}
for($i = 0; $i < count($TaobaokeItem2); $i++){
	if($i<=PAGESIZE){
		$TaobaokeItem[$i]=$TaobaokeItem2[$i];
	}else{
		$ListHot[$i-PAGESIZE-1]=$TaobaokeItem2[$i];
	}
}
//最多显示100页
if($TotalResults>$pagesize*100)
{
	$total=100*$pagesize;
}else
{
	$total=$TotalResults;
}
if($start_price=='0'){$start_price='';}
if($end_price=='999999'){$end_price='';}
//获取卖家昵称字符换
$strnicks = "";
for($i = 0; $i < count($TaobaokeItem); $i++){
	if($i == 0){
		$strnicks = $TaobaokeItem[$i]["nick"]; 
	}else{
		$strnicks = $strnicks . "," . $TaobaokeItem[$i]["nick"]; 
	}
}

//获取卖家信息
$Taoapi->method = 'taobao.users.get';
$Taoapi->fields = 'nick,seller_credit,location,consumer_protection,type';
$Taoapi->nicks = $strnicks;
$TaoapiUsers = $Taoapi->Send('get','xml')->getArrayData();
$Result_users1 = $TaoapiUsers["users"]["user"]; 
if($TotalResults==1){
	$Result_users[0]=$Result_users1;
}else{
	$Result_users=$Result_users1;
}
//网站头
$itemcatsname=$q;
//获取商品类目信息
if($itemcatsname==''){
	include("comm/title.php");
}

for($i=0;$i<$pagesize;$i++){
	if($TaobaokeItem[$i]["nick"]!="")
	{
		$TaobaokeItem[$i]["nick_url"]=urlencode($TaobaokeItem[$i]["nick"]);
		$TaobaokeItem[$i]["level"]=$Result_users[$i]["seller_credit"]["level"]; 
		$TaobaokeItem[$i]["state"]=$Result_users[$i]["location"]["state"]; 
		$TaobaokeItem[$i]["city"]=$Result_users[$i]["location"]["city"]; 
	}
}

//V7.0模板请将以下代码前的//去掉（不包含此行）
//$hotpage=$page+2;
//if($hotpage>100){$hotpage=$hotpage-$page;}
//$TaobaokeParam['method'] = 'taobao.taobaoke.items.get';
//$TaobaokeParam['fields'] = 'iid,num_iid,title,nick,pic_url,price,click_url,shop_click_url,commission,commission_rate,commission_num,commission_volume,volume';
//$TaobaokeParam['nick'] = MYUSERNICK;
//$TaobaokeParam['cid']=$cid;
//$TaobaokeParam['keyword']=$q;
//$TaobaokeParam['start_credit']='1crown';
//$TaobaokeParam['end_credit']='5goldencrown';
//$TaobaokeParam['start_price']='20';
//$TaobaokeParam['end_price']='5000';
//$TaobaokeParam['sort']='commissionNum_desc';
//$TaobaokeParam['area']=$area;
//$TaobaokeParam['page_no']=$hotpage;
//$TaobaokeParam['page_size']='6';
//$TaobaokeParam['outer_code'] = $_SESSION['dduserid'];
//$Taoapi->setUserParam($TaobaokeParam);
//$TaobaokeData2 = $Taoapi->Send('get','xml')->getArrayData();
//$ListHot = $TaobaokeData2["taobaoke_items"]["taobaoke_item"]; 
//V7.0模板专用代码到这里结束（不包含此行）

$tag="list";
include_once 'comm/wjt.php';
$action_url="list.php";
//引入模版文件
include 'template/'.MOBAN.'/list.tpl.php';
mysql_close($cfg_link);
?>